package com.idrive.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.idrive.R;
import com.idrive.database.DatabaseUtility;
import com.idrive.database.dao.CommonDataDao;
import com.idrive.database.dto.CommonData;

public class SMSActivity extends Activity {
	
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_sms);

		final CommonDataDao dao = new CommonDataDao(this);
		
		final EditText editText = (EditText) findViewById(R.id.smsText);

		CommonData data = dao.getCommonData();
		editText.setText(data.getSms());
		
		final Button button = (Button) findViewById(R.id.okDefineSmsButton);
		button.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				CommonData data = new CommonData();
				data.setOption(DatabaseUtility.SETTINGS_OPTION_SMS);
				data.setSms(editText.getText().toString());
				dao.updateCommonData(data);
				
				Toast.makeText(SMSActivity.this, "Call will be automatically rejected and SMS will be automatically sent to the caller.",
						Toast.LENGTH_LONG).show();
				//setContentView(R.layout.activity_call_manager);
				Intent myIntent = new Intent(SMSActivity.this, CallManagerActivity.class);
				SMSActivity.this.startActivity(myIntent);
			}
		});
	}

}
